package com.chinapost.service.impl;

import java.util.HashMap;
import java.util.Map;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.chinapost.action.MonthServiceI;
import com.chinapost.dao.BaseDaoI;
import com.chinapost.po.Tmonth;

@Service("monthService")
public class MonthServiceImpl implements MonthServiceI {
	
	@Autowired
	private BaseDaoI<Tmonth> monthDao;

	@Override
	public void add(Tmonth tmonth) {
		monthDao.saveOrUpdate(tmonth);
	}

	@Override
	public boolean checkMonth(Tmonth tmonth) {
		String hql = " from Tmonth t where t.cid = :id and t.cmonth >=:cmonth";
		Map<String, Object> params = new HashMap<String, Object>();
		params.put("id", tmonth.getCid());
		params.put("cmonth", tmonth.getCmonth());
		Tmonth t = monthDao.get(hql, params);
		if (t != null) {
			return false;
		}
		return true;
	}
}
